import { IPSDataEntity } from '../dataentity/ipsdata-entity';
import { IPSSysEAIDE } from './ipssys-eaide';
import { IPSSysEAIDEField } from './ipssys-eaidefield';
import { IPSSysEAIDER } from './ipssys-eaider';
import { IPSSysEAIElement } from './ipssys-eaielement';
import { IPSSysEAIScheme } from './ipssys-eaischeme';
import { PSModelObjectImpl } from '../psmodel-object-impl';

export class PSSysEAIDEImpl extends PSModelObjectImpl implements IPSSysEAIDE {
  protected allpssyseaidefields: IPSSysEAIDEField[] | null = null;

  getAllPSSysEAIDEFields(): IPSSysEAIDEField[] | null {
    if (this.allpssyseaidefields == null) {
      this.allpssyseaidefields = this.fillChildListModel(this.M.getAllPSSysEAIDEFields, 'eai.IPSSysEAIDEField') as IPSSysEAIDEField[];
    }
    return this.allpssyseaidefields;
  }

  get allPSSysEAIDEFields(): IPSSysEAIDEField[] | null {
    return this.getAllPSSysEAIDEFields();
  }

  findPSSysEAIDEField(objKey: any): IPSSysEAIDEField | null {
    return this.getPSModel5('eai.IPSSysEAIDEField', this.getAllPSSysEAIDEFields(), objKey) as IPSSysEAIDEField;
  }

  protected allpssyseaiders: IPSSysEAIDER[] | null = null;

  getAllPSSysEAIDERs(): IPSSysEAIDER[] | null {
    if (this.allpssyseaiders == null) {
      this.allpssyseaiders = this.fillChildListModel(this.M.getAllPSSysEAIDERs, 'eai.IPSSysEAIDER') as IPSSysEAIDER[];
    }
    return this.allpssyseaiders;
  }

  get allPSSysEAIDERs(): IPSSysEAIDER[] | null {
    return this.getAllPSSysEAIDERs();
  }

  findPSSysEAIDER(objKey: any): IPSSysEAIDER | null {
    return this.getPSModel5('eai.IPSSysEAIDER', this.getAllPSSysEAIDERs(), objKey) as IPSSysEAIDER;
  }

  get codeName(): string {
    return this.M.codeName;
  }

  get dETag(): string {
    return this.M.dETag;
  }

  get dETag2(): string {
    return this.M.dETag2;
  }

  get dynaModelFilePath(): string {
    return this.M.dynaModelFilePath;
  }

  get memo(): string {
    return this.M.memo;
  }

  get name(): string {
    return this.M.name;
  }

  protected psdataentity: IPSDataEntity | null = null;

  getPSDataEntity(): IPSDataEntity | null {
    if (this.psdataentity != null) return this.psdataentity;
    const value = this.M.getPSDataEntity;
    if (value == null) {
      return null;
    }
    this.psdataentity = this.getPSModel4('dataentity.IPSDataEntity', value, 'getPSDataEntity') as IPSDataEntity;
    return this.psdataentity;
  }

  get psDataEntity(): IPSDataEntity | null {
    return this.getPSDataEntity();
  }

  getPSDataEntityMust(): IPSDataEntity {
    const value = this.getPSDataEntity();
    if (value == null) {
      throw new Error('未指定实体');
    }
    return value;
  }

  protected pssyseaielement: IPSSysEAIElement | null = null;

  getPSSysEAIElement(): IPSSysEAIElement | null {
    if (this.pssyseaielement != null) return this.pssyseaielement;
    const value = this.M.getPSSysEAIElement;
    if (value == null) {
      return null;
    }
    const ipssyseaischeme = this.getParentPSModelObject('eai.IPSSysEAIScheme') as IPSSysEAIScheme;
    if (ipssyseaischeme != null) {
      this.pssyseaielement = ipssyseaischeme.findPSSysEAIElement(value);
    }
    return this.pssyseaielement;
  }

  get psSysEAIElement(): IPSSysEAIElement | null {
    return this.getPSSysEAIElement();
  }

  getPSSysEAIElementMust(): IPSSysEAIElement {
    const value = this.getPSSysEAIElement();
    if (value == null) {
      throw new Error('未指定映射集成元素');
    }
    return value;
  }

  get userCat(): string {
    return this.M.userCat;
  }

  get userTag(): string {
    return this.M.userTag;
  }

  get userTag2(): string {
    return this.M.userTag2;
  }

  get userTag3(): string {
    return this.M.userTag3;
  }

  get userTag4(): string {
    return this.M.userTag4;
  }

  get cls(): string {
    return 'PSSysEAIDEImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'eai.IPSEAIDE' || cls == 'eai.IPSSysEAIDE') return true;
    return super.instanceof(cls);
  }
}
